home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
exec
/
stats.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
15KB
|
572 lines
/* ***********************************************************************
STATS PROGRAM FOR FOOTBALL REXX SUITE
---------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 270996 First release.
300996 Amended display for Performance. Tidied some code and
added an error message.
1.1 111196 Added to Football as a callable component. Amended for
different leagues. Fixed bug where if one match was
played, the performance wasn't shown. Fixed bug where
the longest performance record wasn't correctly done.
Removed messages.
131196 Added checks for files - if not found, exits without
a message.
181196 Fixed bug where if 3 matches had been played, the
performance was not printed correctly as the number
of iterations required to format it was wrong.
201196 Added code to display home and away performance.
211196 Updated and tidied the display.
1.2 110497 Added code to support Points_Per_Goals.
151297 Tidied display.
1.3 190499 Added clean sheet to stats and added Key. Remoulded
the display.
1.4 270699 Reorganized code into sections instead one great big
conditional IF. Added code to display highest/lowest
attendances and top goal scorers.
250899 Added error msg to file check.
280899 Converted to use locale. Some error messages, before
reading the locale, will still be in English. Top
goal scorers do not show own goals.
**************************************************************************
Procedure
---------
1. Check files exist. Read Teams.df datafile and store teams and points.
2. Close file. Prompt user for a team to display fixtures for.
3. Display data and open 'Teams.sflearn'.
4. Read data about matches that the selected team has played and store it.
This applies to both home and away matches even though the data is on
different panels.
5. Close file and then display data.
6. Calculate record and performance and then display these. Then exit...
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
title = '*LEAGUE_NAME='
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
separator = '*'
teams. = '???'
counter = 0
not_played = '__ __'
hplay = 0
hwin = 0
hdraw = 0
hloss = 0
hgoals = 0
hagoals = 0
hpts = 0
hcls = 0
aplay = 0
awin = 0
adraw = 0
aloss = 0
agoals = 0
aagoals = 0
apts = 0
acls = 0
ptsgls = 0
home_def = '*HG='
away_def = '*AG='
attd_def = '*ATD='
goalsc. = '???'
goalscorers. = '???'
goalss. = '???'
gscount = 0
gscounter = 0
hamatch = ""
hanum = 0
lamatch = ""
lanum = 999999999
parse var league_stuff league_file search_team
league_file = "Data/" || league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
dfordir = locdir"Football.locale_data"
locdir = locdir"Exec/Stats.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(dfordir) > 0 then do
address command rxdir'rx 'dfordir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot find '"dfordir"' to read date locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say st_error
say
say st_one"'"league_file||input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say st_error
say
say st_one"'"league_file||input2_file"'."
exit
end
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then league_title = delstr(line,1,13)
if pos(points_win,line) > 0 then ptswin=delstr(line,1,16)
if pos(points_drw,line) > 0 then ptsdrw=delstr(line,1,16)
if pos(points_lse,line) > 0 then ptslse=delstr(line,1,16)
if pos(points_gls,line) > 0 then ptsgls=delstr(line,1,16)
if pos(separator,line) = 0 then do
line = strip(line)
if counter = 0 then do
teams.1 = line
counter = 1
end
else do
counter = counter + 1
teams.counter = line
end
end
end
close(datafile)
end
else do
say
say st_error
say
say st_two"'"league_file || input_file"'."
end
sel=-1
search_team = strip(search_team)
do i=1 to counter
if pos(search_team,teams.i) > 0 then sel = i
end
if sel < 1 then do
say
say st_error
say
say st_three"'"search_team"'"st_four
exit
end
say
say center(st_txt1"'"league_title"'",78)
say "-------------------------------------------------------------------------------"
say
say
say st_txt2""upper(teams.sel)
say
say
say
matches = 0
lrecord = ''
awayperf= ''
homeperf= ''
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(not_played,line) = 0 then do
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
strng = strip(teams.sel)
if strng = home_team then do
if goals_aga = 0 then
hcls = hcls + 1
if goals_for > goals_aga then do
hwin = hwin + 1
ltemp = st_txtq
hpts = hpts + ptswin
end
if goals_for = goals_aga then do
hdraw = hdraw + 1
ltemp = st_txtr
hpts = hpts + ptsdrw
end
if goals_for < goals_aga then do
hloss = hloss + 1
ltemp = st_txts
hpts = hpts + ptslse
end
lrecord = insert(ltemp,lrecord,matches+1,1)
homeperf= insert(ltemp,homeperf,hplay+1,1)
hgoals = hgoals + goals_for
hagoals = hagoals+ goals_aga
hplay = hplay + 1
matches = matches + 1
hpts = hpts + (goals_for * ptsgls)
end
if strng = away_team then do
if goals_for = 0 then
acls = acls + 1
if goals_for > goals_aga then do
aloss = aloss + 1
ltemp = st_txts
apts = apts + ptslse
end
if goals_for = goals_aga then do
adraw = adraw + 1
ltemp = st_txtr
apts = apts + ptsdrw
end
if goals_for < goals_aga then do
awin = awin + 1
ltemp = st_txtq
apts = apts + ptswin
end
lrecord = insert(ltemp,lrecord,matches+1,1)
awayperf= insert(ltemp,awayperf,aplay+1,1)
agoals = agoals + goals_aga
aagoals = aagoals+ goals_for
aplay = aplay + 1
matches = matches + 1
apts = apts + (goals_aga * ptsgls)
end
end
end
end
close(datafile)
end
else do
say
say st_error
say
say st_two"'"league_file || input2_file"'."
exit
end
/* code to check for top goal scorer and attendances */
j = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
j = 0
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
strng = strip(teams.sel)
if strng = home_team then
j = 1
if strng = away_team then
j = 2
end
else do
if j > 0 then do
if pos(home_def,line) > 0 & j = 1 then do
gscount = gscount + 1
parse var line "*HG=" goalsc.gscount
end
if pos(away_def,line) > 0 & j = 2 then do
gscount = gscount + 1
parse var line "*AG=" goalsc.gscount
end
if pos(attd_def,line) > 0 then do
parse var line "*ATD=" attend
if attend > hanum then do
hanum = attend
hamatch = home_team""txt_versus""away_team
end
if attend < lanum then do
lanum = attend
lamatch = home_team""txt_versus""away_team
end
end
end
end
end
close(datafile)
end
else do
say
say st_error
say
say st_two"'"league_file || input2_file"'."
exit
end
if gscount > 0 then do
do gsc=1 to gscount
if pos("(P)",goalsc.gsc) > 0 then do
kl = pos("(P)",goalsc.gsc)
goalsc.gsc = delstr(goalsc.gsc,kl,3)
end
klk = words(goalsc.gsc)
if datatype(word(goalsc.gsc,klk)) = "NUM" then
goalsc.gsc = delword(goalsc.gsc,klk,1)
end
do gsc=1 to gscount
name = goalsc.gsc
notin = 0
do ii=1 to gscounter
if pos(name,goalscorers.ii) > 0 then do
goalss.ii = goalss.ii + 1
notin = 1
end
end
if notin = 0 then do
gscounter = gscounter + 1
goalscorers.gscounter = name
goalss.gscounter = 1
end
end
end
if gscounter > 1 then do
if open(datafile,"RAM:Football.tempcup",'w') then do
do ii=1 to gscounter
if pos("(og)",goalscorers.ii) = 0 then
writeln(datafile,left(goalss.ii,4)" "goalscorers.ii)
end
close(datafile)
end
else do
say
say st_error
say
say st_txt3
exit
end
address command 'Exec/Sort4Chars '
end
say
if matches = 0 then do
say st_txt4
say
end
else do
say st_txt5
say
say st_txt6
say " -------------------------------------- --------------------------------------"
h1 = " "left(hplay,3)" "
h2 = left(hwin,3)" "
h3 = left(hdraw,3)" "
h4 = left(hloss,3)" "
h5 = left(hgoals,4)" "
h6 = left(hagoals,4)" "
h7 = left(hpts,6)" "
h8 = left(hcls,4)" "
a1 = left(aplay,3)" "
a2 = left(awin,3)" "
a3 = left(adraw,3)" "
a4 = left(aloss,3)" "
a5 = left(agoals,4)" "
a6 = left(aagoals,4)" "
a7 = left(apts,6)
a8 = left(acls,4)" "
say h1||h2||h3||h4||h8||h5||h6||h7||a1||a2||a3||a4||a8||a5||a6||a7
say
say
say
say
say
re = 0
lre = 0
do i=1 to matches+1
if substr(lrecord,i,1) = st_txtq then re = re + 1
if substr(lrecord,i,1) = st_txtr then re = re + 1
if substr(lrecord,i,1) = st_txts then do
if re > lre then lre = re
re = 0
end
end
if lre = 0 then lre = re
lrecord = strip(lrecord)
countr = (matches * 2) - 1
if matches > 8 then do
lrecord = right(lrecord,8)
countr = 15
end
call format_perf(lrecord,countr)
if countr = 1 then ptemp = lrecord
if matches < 9 then
say st_txt7""matches""st_txt8""ptemp
else
say st_txt9""ptemp
homeperf=strip(homeperf)
hcountr = (hplay * 2) - 1
if hplay > 8 then do
homeperf = right(homeperf,8)
hcountr = 15
end
call format_perf(homeperf,hcountr)
if hplay = 1 then ptemp = homeperf
say
say st_txt0""ptemp
awayperf=strip(awayperf)
acountr = (aplay * 2) - 1
if aplay > 8 then do
awayperf = right(awayperf,8)
acountr = 15
end
call format_perf(awayperf,acountr)
if aplay = 1 then ptemp = awayperf
say
say st_txta""ptemp
say
say
say
say st_txtb""re""st_txtc
say st_txtd""lre""st_txtc
say
say
if hanum > 0 then do
say st_txte""left(hanum,6)""st_txtf""hamatch
say
end
if lanum ~= 999999999 then do
say st_txtg""left(lanum,6)""st_txtf""lamatch
say
end
if gscounter > 0 then do
say
say st_txth
say st_txti
say
say " "st_txtt
st_line = ""
do dp=1 to length(st_txtt)+3
st_line = st_line"-"
end
say " "st_line
say
if gscounter = 1 then do
say left(goalss.1,4)" "goalscorers.1
say
end
else do
ii = 0
if open(datafile,"RAM:Football.tempcup",'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= "" then do
ii = ii + 1
say " "right(ii,2)") "line
end
end
close(datafile)
end
else do
say
say st_error
say
say st_txtj
exit
end
address command 'delete >NIL: RAM:Football.tempcup'
end
end
say
say
say
say
say
say
say
end
say "-------------------------------------------------------------------------------"
say st_txtk
say st_txtl
say st_txtm
say st_txtn
say st_txto
say st_txtp
exit
/* Routine ----------------------------------------------------------- */
format_perf:
ARG fstrg,counter
ptemp = ''
i = 1
j = 1
do while i <= counter
ptemp = insert(substr(fstrg,j,1),ptemp,i,1)
i = i + 1
j = j + 1
if i < counter then do
ptemp = insert(".",ptemp,i,1)
i = i + 1
end
end
ptemp = strip(ptemp)
return
/* ------------------------------------------------------------------- */